------------------------------------------------------------
-- OnlyMyBadges.lua
--
-- Abin
-- 2009-7-19
------------------------------------------------------------

local BADGES = { ["29434"] = 1, ["45624"] = 1, ["40752"] = 1, ["40753"] = 1, ["43228"] = 1, ["28558"] = 1, ["20560"] = 1, ["20559"] = 1,
	["29024"] = 1, ["42425"] = 1, ["20558"] = 1, ["43589"] = 1,  ["30311"] = 1, ["30312"] = 1, ["30313"] = 1, ["30314"] = 1, ["30316"] = 1,
	["30317"] = 1, ["30318"] = 1, ["30319"] = 1, ["47241"] = 1, ["44990"] = 1, ["47395"] = 1}

local strreplace = string.gsub
local strfind = string.find
local type = type

local LOOT_MSG = strreplace(LOOT_ITEM, "%%s", "(.+)")
local LOOT_MSG_MULTIPLE = strreplace(strreplace(LOOT_ITEM_MULTIPLE, "%%s", "(.+)"), "%%d", "(%%d+)")

local function BadgesFilter(self, event, text)
	if type(text) == "string" then
		local _, _, name, lnk = strfind(text, LOOT_MSG)
		if not name then
			_, _, name, lnk = strfind(text, LOOT_MSG_MULTIPLE)
		end

		if lnk and name ~= YOU then
			local _, _, id = strfind(lnk, "item:(%d+)")
			if id and BADGES[id] then
				return true
			end
		end	
	end
	return false
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", BadgesFilter)